# Configure to your system's settings

CC=avr-gcc
LINK=avr-gcc
OBJCOPY=avr-objcopy
SIZE=avr-size
RM=rm -rf

ELF=t45-counter.elf
HEX=t45-counter.hex
MAP=t45-counter.map

MMCU=attiny45
F_CPU=1000000UL

CFLAGS=-Wall -Os -fpack-struct -fshort-enums -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=$(MMCU) -DF_CPU=$(F_CPU)
LDFLAGS=-Wl,-Map,$(MAP) -mmcu=$(MMCU)
LIBS=-lm
SFLAGS=--format=avr --mcu=$(MMCU)

SRC=core.c
OBJ=core.o

all: object elf hex size

object: $(SRC)
	$(CC) $(CFLAGS) -c $(SRC) -o $(OBJ)

elf: $(OBJ)
	$(CC) $(LDFLAGS) -o $(ELF) $(OBJ) $(LIBS)

hex: $(ELF)
	$(OBJCOPY) -R .eeprom -O ihex $(ELF) $(HEX)

size: $(ELF)
	$(SIZE) $(SFLAGS) $(ELF)

clean:
	-$(RM) $(OBJ) $(HEX) $(ELF) $(MAP)

